/**
 * 初始化部标准字典详情对话框
 */
var SdsStandDicInfoDlg = {
    zTreeInstance: null,
    validateFields: {
        name: {
            validators: {
                notEmpty: {
                    message: '字典名称不能为空'
                }
            }
        }
    }
};


/**
 * 关闭此对话框
 */
SdsStandDicInfoDlg.close = function () {
    parent.layer.close(window.parent.StandDic.layerIndex);
}



/**
 * 验证数据是否为空
 */
SdsStandDicInfoDlg.validate = function () {
    $('#sdsStandDicInfoForm').data("bootstrapValidator").resetForm();
    $('#sdsStandDicInfoForm').bootstrapValidator('validate');
    return $("#sdsStandDicInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交添加部门
 */
SdsStandDicInfoDlg.addSubmit = function () {
    if (!this.validate()) {
        return;
    }

    //提交信息
    /*Sys.ajaxForm('sdsStandDicInfoForm', Sys.backendPath + "/sds/sdsstanddic/add", function (res) {
        Sys.success("添加成功!");
        window.parent.StandDic.refresh();
        SdsStandDicInfoDlg.close();
    });*/
    var queryData = {};
    var ajax = new $ax(Sys.backendPath + "/sds/sdsstanddic/add", function (data) {
        Sys.success("修改成功!");
        window.parent.StandDic.refresh();
        SdsStandDicInfoDlg.close();
    }, function (data) {
        Sys.error("修改失败!" + data.responseJSON.message + "!");
    });
    //ajax.set(this.qcRuleData);
    queryData['id'] = $("#id").val();
    queryData['name'] =encodeURIComponent( $("#name").val());
    queryData['resume'] = $("#resume").val();
    queryData['parentId'] = $('#parentId').combotree('getValue');//$("#parentId").val();
    //queryData['compareType'] =  $("#compareType option:selected").val();
    queryData['compareType'] =  $("#compareType").combobox('getValue');
    ajax.setData(queryData);
    ajax.start();
}

/**
 * 提交修改
 */
SdsStandDicInfoDlg.editSubmit = function () {

    if (!this.validate()) {
        return;
    }

    //提交信息
   /* Sys.ajaxForm('sdsStandDicInfoForm', Sys.backendPath + "/sds/sdsstanddic/update", function (res) {
        Sys.success("修改成功!");
        window.parent.StandDic.refresh();
        SdsStandDicInfoDlg.close();
    });*/
    var queryData = {};
    var ajax = new $ax(Sys.backendPath + "/sds/sdsstanddic/update", function (data) {
        Sys.success("修改成功!");
        window.parent.StandDic.refresh();
        SdsStandDicInfoDlg.close();
    }, function (data) {
        Sys.error("修改失败!" + data.responseJSON.message + "!");
    });
    //ajax.set(this.qcRuleData);
    queryData['id'] = $("#id").val();
    queryData['name'] =encodeURIComponent( $("#name").val());
    queryData['resume'] = $("#resume").val();
    queryData['parentId'] = $('#parentId').combotree('getValue');//$("#parentId").val();
    // queryData['parentId'] = $("#parentId").val();
    //queryData['compareType'] =  $("#compareType option:selected").val();
    queryData['compareType'] =  $("#compareType").combobox('getValue');
    ajax.setData(queryData);
    ajax.start();
}

$(function () {
    $HUI.combotree('#parentId',{
        url: '/sds/sdsstanddic/getDicTree/'+"0"
    });

    Sys.initValidator("sdsStandDicInfoForm", SdsStandDicInfoDlg.validateFields);
});

